﻿using System;
using System.ComponentModel;

namespace HalconDotNet
{
	/// <summary>Represents an instance of a connection to a gnuplot process.</summary>
	// Token: 0x0200003E RID: 62
	public class HGnuplot : HHandle
	{
		// Token: 0x060005B3 RID: 1459 RVA: 0x0000883B File Offset: 0x00006A3B
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HGnuplot() : base(HHandleBase.UNDEF)
		{
		}

		// Token: 0x060005B4 RID: 1460 RVA: 0x000209EA File Offset: 0x0001EBEA
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HGnuplot(IntPtr handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x060005B5 RID: 1461 RVA: 0x000209F9 File Offset: 0x0001EBF9
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HGnuplot(HHandle handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x060005B6 RID: 1462 RVA: 0x00020A08 File Offset: 0x0001EC08
		private void AssertSemType()
		{
			base.AssertSemType("gnuplot");
		}

		// Token: 0x060005B7 RID: 1463 RVA: 0x00020A15 File Offset: 0x0001EC15
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HGnuplot obj)
		{
			obj = new HGnuplot(HHandleBase.UNDEF);
			return obj.Load(proc, parIndex, err);
		}

		// Token: 0x060005B8 RID: 1464 RVA: 0x00020A30 File Offset: 0x0001EC30
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HGnuplot[] obj)
		{
			HTuple htuple;
			err = HTuple.LoadNew(proc, parIndex, err, out htuple);
			obj = new HGnuplot[htuple.Length];
			for (int i = 0; i < htuple.Length; i++)
			{
				obj[i] = new HGnuplot(HalconAPI.IsLegacyHandleMode() ? htuple[i].IP : htuple[i].H);
			}
			htuple.Dispose();
			return err;
		}

		/// <summary>
		///   Plot a function using gnuplot.
		///   Instance represents: Identifier for the gnuplot output stream.
		/// </summary>
		/// <param name="function">Function to be plotted.</param>
		// Token: 0x060005B9 RID: 1465 RVA: 0x00020AA0 File Offset: 0x0001ECA0
		public void GnuplotPlotFunct1d(HFunction1D function)
		{
			IntPtr proc = HalconAPI.PreCall(1295);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, function);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(function);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Plot control values using gnuplot.
		///   Instance represents: Identifier for the gnuplot output stream.
		/// </summary>
		/// <param name="values">Control values to be plotted (y-values).</param>
		// Token: 0x060005BA RID: 1466 RVA: 0x00020AEC File Offset: 0x0001ECEC
		public void GnuplotPlotCtrl(HTuple values)
		{
			IntPtr proc = HalconAPI.PreCall(1296);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, values);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(values);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Visualize images using gnuplot.
		///   Instance represents: Identifier for the gnuplot output stream.
		/// </summary>
		/// <param name="image">Image to be plotted.</param>
		/// <param name="samplesX">Number of samples in the x-direction. Default: 64</param>
		/// <param name="samplesY">Number of samples in the y-direction. Default: 64</param>
		/// <param name="viewRotX">Rotation of the plot about the x-axis. Default: 60</param>
		/// <param name="viewRotZ">Rotation of the plot about the z-axis. Default: 30</param>
		/// <param name="hidden3D">Plot the image with hidden surfaces removed. Default: "hidden3d"</param>
		// Token: 0x060005BB RID: 1467 RVA: 0x00020B30 File Offset: 0x0001ED30
		public void GnuplotPlotImage(HImage image, int samplesX, int samplesY, HTuple viewRotX, HTuple viewRotZ, string hidden3D)
		{
			IntPtr proc = HalconAPI.PreCall(1297);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, image);
			HalconAPI.StoreI(proc, 1, samplesX);
			HalconAPI.StoreI(proc, 2, samplesY);
			HalconAPI.Store(proc, 3, viewRotX);
			HalconAPI.Store(proc, 4, viewRotZ);
			HalconAPI.StoreS(proc, 5, hidden3D);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(viewRotX);
			HalconAPI.UnpinTuple(viewRotZ);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
			GC.KeepAlive(image);
		}

		/// <summary>
		///   Visualize images using gnuplot.
		///   Instance represents: Identifier for the gnuplot output stream.
		/// </summary>
		/// <param name="image">Image to be plotted.</param>
		/// <param name="samplesX">Number of samples in the x-direction. Default: 64</param>
		/// <param name="samplesY">Number of samples in the y-direction. Default: 64</param>
		/// <param name="viewRotX">Rotation of the plot about the x-axis. Default: 60</param>
		/// <param name="viewRotZ">Rotation of the plot about the z-axis. Default: 30</param>
		/// <param name="hidden3D">Plot the image with hidden surfaces removed. Default: "hidden3d"</param>
		// Token: 0x060005BC RID: 1468 RVA: 0x00020BAC File Offset: 0x0001EDAC
		public void GnuplotPlotImage(HImage image, int samplesX, int samplesY, double viewRotX, double viewRotZ, string hidden3D)
		{
			IntPtr proc = HalconAPI.PreCall(1297);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, image);
			HalconAPI.StoreI(proc, 1, samplesX);
			HalconAPI.StoreI(proc, 2, samplesY);
			HalconAPI.StoreD(proc, 3, viewRotX);
			HalconAPI.StoreD(proc, 4, viewRotZ);
			HalconAPI.StoreS(proc, 5, hidden3D);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
			GC.KeepAlive(image);
		}

		/// <summary>
		///   Close all open gnuplot files or terminate an active gnuplot sub-process.
		///   Instance represents: Identifier for the gnuplot output stream.
		/// </summary>
		// Token: 0x060005BD RID: 1469 RVA: 0x00020C1C File Offset: 0x0001EE1C
		public void GnuplotClose()
		{
			IntPtr proc = HalconAPI.PreCall(1298);
			base.Store(proc, 0);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Open a gnuplot file for visualization of images and control values.
		///   Modified instance represents: Identifier for the gnuplot output stream.
		/// </summary>
		/// <param name="fileName">Base name for control and data files.</param>
		// Token: 0x060005BE RID: 1470 RVA: 0x00020C50 File Offset: 0x0001EE50
		public void GnuplotOpenFile(string fileName)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1299);
			HalconAPI.StoreS(proc, 0, fileName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Open a pipe to a gnuplot process for visualization of images and control values.
		///   Modified instance represents: Identifier for the gnuplot output stream.
		/// </summary>
		// Token: 0x060005BF RID: 1471 RVA: 0x00020C9C File Offset: 0x0001EE9C
		public void GnuplotOpenPipe()
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1300);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}
	}
}
